﻿using BinaryKits.Zpl.Viewer;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace ZPLPrint
{
    public partial class Form3 : Form
    {
        CommonHelper CommonH = new CommonHelper();

        public Form3()
        {
            InitializeComponent();
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            string Print = CommonH.getBoxFlie(Application.StartupPath + @"\template\Test.prn");

            IPrinterStorage printerStorage = new PrinterStorage();
            var drawer = new ZplElementDrawer(printerStorage);

            var analyzer = new ZplAnalyzer(printerStorage);
            var analyzeInfo = analyzer.Analyze(Print);

            foreach (var labelInfo in analyzeInfo.LabelInfos)
            {
                var imageData = drawer.Draw(labelInfo.ZplElements);
                File.WriteAllBytes("label.png", imageData);
            }
        }
    }
}
